home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / Compilers / Miracle C Compiler / miricleC compiler.msi / Instal01.cab / _D4B9BD7AFB594996BC459A0F30288F61 < prev    next >
Encoding:
Text File  |  2000-08-13  |  1.5 KB  |  71 lines

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <assert.h>
  4. #include <system.h>
  5. #include <string.h>
  6. #include <time.h>
  7.  
  8. void xroot();
  9.  
  10. int main(int argc, char **argv)
  11. {
  12.     int i;
  13.  
  14.     printf("start of command line parameters, argc=%d\n",argc);
  15.     for(i=0; i<argc; i++)
  16.         printf("[%d][%s]\n",i,argv[i]);
  17.     printf("end of command line parameters\n");
  18.  
  19.     xroot();
  20. }
  21.  
  22. void xroot()
  23. {
  24.     int i,j;
  25.     char *p[10], buf[150];
  26.     struct REGS ireg,oreg;
  27.  
  28.     printf("==> starting xroot <==\n");
  29.  
  30.     // --- try out getenv
  31.     printf("COMSPEC\t=>%s<=\n",getenv("COMSPEC"));    assert(strlen(getenv("COMSPEC"))>0);
  32.     printf("PROMPT\t=>%s<=\n",getenv("PROMPT"));    assert(strlen(getenv("PROMPT"))>0);
  33.     printf("passed getenv...\n");
  34.  
  35.     // --- now try malloc and free
  36.     for(i=0; i<10; i++)
  37.         {
  38.         p[i]=malloc((j=rand() & 0xfff));
  39.         printf("%d,%d,%p\t",i,j,p[i]);
  40.         }
  41.  
  42.     for(i=0; i<10; i++)
  43.         free(p[i]);
  44.  
  45.     p[0]=malloc(100); printf("\nnew malloc=%p\n",p[0]); free(p[0]);
  46.  
  47.     // --- test int86
  48.     ireg.ax=0x4700;        /* getcd */
  49.     ireg.dx=0;        /* c drive */
  50.     ireg.si=(unsigned)buf;
  51.     int86(0x21,&ireg,&oreg);
  52.     printf("getcd ->%s<-\n",buf);
  53.  
  54.     printf("bios_clock; %lu;",bios_clock());
  55.     sleep(2L);
  56.     printf(" (+2 sec) %lu;\n",bios_clock());
  57.  
  58.     printf("please press an alphabetic key...");
  59.     while(!kbhit()) { sleep(1L); printf("."); }
  60.     printf("%c.\n",getch());
  61.  
  62.     printf("please press another alphabetic key...");
  63.     while(!kbhit()) { sleep(1L); printf("."); }
  64.     printf("%c.\n",getche());
  65.  
  66.     printf("passed root tests...\n");
  67.     printf("==> finished xroot <==\n");
  68.  
  69.     return;
  70. }
  71.